Skip to content

crypto: foundation increment 2, libsecp256k1's ECDH forms, recovery, ElligatorSwift, MuSig2 and silent payments - #5

Merged
pinhopro merged 54 commits into
mainfrom
crypto/secp256k1-modules
Nov 20, 2026
Merged

pinhopro merged 54 commits into
mainfrom
crypto/secp256k1-modules

Conversation

@pinhopro

@pinhopro pinhopro commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What this brings

webcpp::crypto's foundation, increment 2: libsecp256k1's remaining modules over the same patterns as increment 1.

  • ECDH: ecdh returns secret<32>, ecdh_x and ecdh_point (raw and hashed forms).
  • public_key (ordered, both point forms), parse and serialize, recoverable ECDSA and recover, hedged ECDSA with extra entropy.
  • BIP 324's ElligatorSwift, BIP 327's MuSig2 (secret nonces consumed by construction, serialisation of every public piece, x-only tweaks), BIP 352's silent payments (caller-lent workspace, label lookups of an exact result type).
  • secp256k1 SPKI, PKCS#8 and PEM.
  • Per-family defaults and refusals for the three module families; constant-time cases (memcheck, MSan, dudect) and release-built sizes for them; teaching chapters; two new tested MuSig2 examples (network byte buffers, a Taproot key-path output).

Verification (local, on the final heads, before this PR)

  • Full lint: clean. generate.py --check and generate_test.py: clean.
  • Lanes from scratch, -a, test and example: native 344, gcc-15 307, wasip2 303, wasip3 291, emscripten 230; 0 failed, 0 warnings.
  • Constant time: dudect ecdh_x at 500k measurements, judged: macOS (under DIT) |t| 1.33, wasip2 2.86, Linux container 1.99; Linux container (memcheck, MSan) 11/11 with B's module cases clean and the planted leaks caught.
  • Release size tables unchanged on four targets; C suites on four targets; docs, site and site-test 97/97; the changed pages checked rendered at 1280 px and 375 px.
  • Tools tests 64/64; crypto_jamfiles_test on native, wasip2, wasip3, emscripten.
  • Local MSVC lane (real cl.exe under Wine): 14.3 and 14.5 each 570 passed, 0 new failures, 22 known Wine artifacts (three new Boost.JSON no-exception lines of the documented class); crypto 337 and test/msvc 46/46 pass, incl. the label_lookup_by_value and musig_nonce_copied compile-fail cases. One real MSVC /WX failure (C4244 in two tests) was found and fixed.
  • Not run locally: the CI's x86-64 container lanes and Apple Clang.

For the owner

  • Base: this branch starts from stream A's heads as merged (crypto 1fc5140 / webcpp c00bf7a, the second parents of dae9e84 and 485c5e0, same trees), so it lists only increment 2's commits.
  • label_lookup (silent payments) now requires a lookup to return exactly std::optional<std::span<const std::uint8_t, 32>>: a by-value result left the span dangling on libstdc++ and MSVC. Pinned by static_asserts on every lane and a compile-fail case per compiler.
  • Two examples requested in chat (musig_network, musig_taproot) run on every lane against their .expected output and are on the secp256k1 page.
  • No application is named in the teaching sections (primitives only, D24).
  • The changelog stays within its 10-line, 30-word form, so increment 2 is merged into the existing secp256k1 and capability lines.

Related PRs

🤖 Generated with Claude Code

R added 30 commits November 19, 2026 17:21
…l says what a raw x costs; the session example wipes its shared secrets once the ciphers are made

Task 2.1's review, Minors 2 to 7: crypto.json gains the sources sec1 and
wycheproof; the uncompressed encoding is cited to SEC 1, not SEC 2; the raw
x coordinate's pitfall cites SEC 1 for the points' x and names the cost; the
ECDH test returns when libsecp256k1 refuses a point webcpp took, instead of
reaching its illegal callback; ecdh_session scopes its shared secrets; the
memory page's edited line is rewrapped.
…2.2 added; recover reads the canary before the id's check; the changelog's secp256k1 line reads plainly
…ry first; a workspace is wiped whole, off-alignment ones tested; the tweak example wipes on every path; the pages cite OpenSSL and name tweaks and key files
…e change label, which scan_outputs leaves out by default
…ilies of their own, refused and defaulted by the generated table
…ly's comment names the namespace of its header
R added 24 commits November 19, 2026 17:21
…re size_t and the access helper returns {}
…as its specialization, which clang-tidy reads without a cast
…maller functions, unsigned flips, a const moved-to key pair
…ons, reserved vectors, trailing commas, unsigned flips
…eserved vector, trailing commas, main's complexity named
… keeps raw and hashed ECDH in the secp256k1 line
…, its verdicts and the key pairs' public keys marked public where webcpp reads them, and dudect times ecdh_x
…atorSwift's BIP 324 exchange, a two-signer MuSig2 signature and a silent payment output, from release builds
…tures, MuSig2, silent payments, Nostr's shared key and BIP 324's handshake, and the curves pages list secp256k1's functions by header
…that dudect's names ecdh_x alone and MemorySanitizer's the paths memcheck runs
…it answers, so that llms.txt keeps its Use it to for recover, ElligatorSwift, MuSig2 and silent payments
… dudect_secp256k1 checks the peer's public key, and the constant-time paths check the decoded PKCS#8 pair and the MuSig2 secret nonce traced
…network as bytes and checked before they are added, and a Taproot key-path output tweaked before any nonce
…an into bytes it owns, so that a tweak returned by value, which libsecp256k1 would read after it is gone, is refused at compile time on every standard library
…y guide names ElligatorSwift, MuSig2 and silent payments among what allocates nothing, and the Taproot example says the session and the parts need the tweaked key
… damaged one, so that the refusal reads as the same check's
…<std::uint8_t> lists, not braced int lists, whose conversion to std::uint8_t MSVC warns of (C4244, an error under /WX)
@pinhopro
pinhopro merged commit 6fc9d7a into main Nov 20, 2026
3 of 36 checks passed
@pinhopro
pinhopro deleted the crypto/secp256k1-modules branch November 20, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant